# /usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2022/1/11 11:50
# @Author  : lt
# @Email   : lt@163.com
# @File    : add_kehu_page.py
# @Software: PyCharm
from selenium.webdriver.common.by import By
from page.KHGL_page.Base_Page import BasePage
from selenium.webdriver.support.select import Select
class Add_KeHu_Page(BasePage):
    # 定位客户池
    kehuchi_locator = (By.ID, 'remove')
    # 定位客户名称输入框
    kehu_name_locator = (By.ID, 'name')
    # 定位行业输入框
    hangye_locator = (By.ID, 'industry')
    # 定位客户来源输入框
    kehu_laiyuan_locator = (By.ID, 'origin')
    # 定位公司性质输入框
    gongsi_xingzhi_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[4]/td[2]')
    # 定位公司营业额输入框
    yingyee_locator = (By.ID, 'annual_revenue')
    # 定位省级地址
    adress_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(6) > td:nth-child(2) > select:nth-child(2)')
    # 定位城市输入框
    city_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(6) > td:nth-child(2) > select:nth-child(3)')
    # 定位地区输入框
    area_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(6) > td:nth-child(2) > select:nth-child(4)')
    # 定位联系人输入框
    lianxi_person_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(8) > td:nth-child(2) > input')
    # 定位尊称输入框
    zuncheng_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(8) > td:nth-child(4) > input')
    # 定位邮箱输入框
    email_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(9) > td:nth-child(2) > input')
    # 定位职位输入框
    zhiwei_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(8) > td:nth-child(4) > input')
    # 定位QQ输入框
    qq_locator = (By.NAME, 'con_qq')
    # 定位手机输入框
    moible_locator = (By.NAME, 'con_telephone')
    # 定位备注输入框
    beizhu_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(11) > td:nth-child(2) > textarea')
    # 定位员工人数输入框
    yuangong_num_locator = (By.ID, 'no_of_employees')
    # 定位描述输入框
    description_locator = (By.ID, 'description')
    # 定位保存按钮
    baocun_locator = (By.CSS_SELECTOR, '#form1 > table > tfoot > tr > td > input:nth-child(1)')
    # 定位添加客户成功
    succful_locator = (By.CSS_SELECTOR, 'body > div.container > div.alert.alert-success')

    # 点击放入客户池按钮
    def kehuchi_button(self):
        self.driver.find_element(*self.kehuchi_locator).click()
    # 输入客户名称
    def kehu_name(self,name):
        self.driver.find_element(*self.kehu_name_locator).send_keys(name)
    # 输入客户行业
    def kehu_hangye(self,hangye):
        Select(self.driver.find_element(*self.hangye_locator)).select_by_visible_text(hangye)
    # 输入客户来源
    def kehu_laiyuan(self,laiyuan):
        Select(self.driver.find_element(*self.kehu_laiyuan_locator)).select_by_visible_text(laiyuan)
    # 输入性质
    def gongsi_xingzhi(self,gongsixingzhi):
        tds = self.driver.find_element(*self.gongsi_xingzhi_locator)
        td = tds.find_elements(By.TAG_NAME, 'input')
        for i in td:
            if i.get_attribute('value') == gongsixingzhi:
                i.click()
                break
    # 输入年营业额
    def nian_yingyee(self,yingyee):
        Select(self.driver.find_element(*self.yingyee_locator)).select_by_visible_text(yingyee)
    # 输入省级地址
    def shengji_adress(self,shengji):
        Select(self.driver.find_element(*self.adress_locator)).select_by_visible_text(shengji)
    # 输入市级地址
    def city_adress(self,city):
        Select(self.driver.find_element(*self.city_locator)).select_by_visible_text(city)
    # 输入地区
    def area_adress(self,diqu):
        Select(self.driver.find_element(*self.area_locator)).select_by_visible_text(diqu)
    # 输入联系人
    def lianxiren_shurukuang(self,lianxiren):
        self.driver.find_element(*self.lianxi_person_locator).send_keys(lianxiren)
    # 输入尊称
    def zuncheng_xialakuang(self,zuncheng):
        self.driver.find_element(*self.zuncheng_locator).send_keys(zuncheng)
    # 输入邮箱
    def email_shuru(self,email):
        self.driver.find_element(*self.email_locator).send_keys(email)
    # 输入职位
    def zhiwei_shuru(self,zhiwei):
        self.driver.find_element(*self.zhiwei_locator).send_keys(zhiwei)
    # 输入QQ
    def qq_shuru(self,qq):
        self.driver.find_element(*self.qq_locator).send_keys(qq)
    # 输入电话
    def mobile_shuru(self,mobile):
        self.driver.find_element(*self.moible_locator).send_keys(mobile)
    # 输入备注
    def beizhu_shuru(self,beizhu):
        self.driver.find_element(*self.beizhu_locator).send_keys(beizhu)
    # 输入员工人数
    def yuangong(self,yuangong_num):
        Select(self.driver.find_element(*self.yuangong_num_locator)).select_by_visible_text(yuangong_num)
    # 输入描述
    def description_shuru(self,description):
        self.driver.find_element(*self.description_locator).send_keys(description)
    # 点击保存
    def baocun_click(self):
        self.driver.find_element(*self.baocun_locator).click()
    # 断言
    def tianjian_succeful(self):
        text = self.driver.find_element(*self.succful_locator).text
        return text
